/*
 * @(#)RegistryResponse.java
 * Date 2013-09-25
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.model;

import java.util.Arrays;

import us.hornerscorners.lamppost.exception.ServiceActionError;
import us.hornerscorners.lamppost.exception.ServiceActionException;

import us.hornerscorners.lamppost.registry.constant.ResponseStatus;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-25
 * @author         Jim Horner
 */
public class RegistryResponse {

    /** Field description */
    private final ServiceActionException exception;

    /** Field description */
    private final ResponseStatus responseStatus;

    /**
     * Constructs ...
     *
     *
     * @param responseStatus
     */
    public RegistryResponse(ResponseStatus responseStatus) {

        this(responseStatus, null);
    }

    /**
     * Constructs ...
     *
     *
     * @param responseStatus
     * @param exception
     */
    public RegistryResponse(ResponseStatus responseStatus,
                            ServiceActionException exception) {

        super();
        this.responseStatus = responseStatus;
        this.exception = exception;
    }

    /**
     * Constructs ...
     *
     *
     * @param responseStatus
     * @param errorLocation
     * @param error
     */
    public RegistryResponse(ResponseStatus responseStatus, Class errorLocation,
                            ServiceActionError error) {

        this(responseStatus, new ServiceActionException(errorLocation, error));
    }

    /**
     * Constructs ...
     *
     *
     * @param responseStatus
     * @param errorLocation
     * @param errors
     */
    public RegistryResponse(ResponseStatus responseStatus, Class errorLocation,
                            ServiceActionError[] errors) {

        this(responseStatus,
             new ServiceActionException(errorLocation, Arrays.asList(errors)));
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public ServiceActionException getException() {
        return exception;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public ResponseStatus getResponseStatus() {
        return responseStatus;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    public boolean hasErrors() {

        boolean result = false;

        if ((this.exception != null) && this.exception.hasErrors()) {

            result = true;
        }

        return result;
    }
}
